import java.util.ArrayList;
import java.util.NoSuchElementException;

/**
 * Player class keeps track of a player for the
 * game Svoi Kozyri. Can either be human or AI.
 * Keeps track of the type of player, their trump
 * suit, and their hand. Can return the player's trump, 
 * their entire hand, their type, or if they're hand
 * is empty.Can add a card or remove a card.
 * 
 * @author Malcheck s'Palcheck Team
 */
public class Player
{  
   private int _type;
   private int _trump;
   private int _playerNum;
   protected Hand<Card> _hand;
   
   
   /**
    * Constructs a player object with a given type and player number
    * 
    * @param type 1 = human, 0 = AI
    * @param player number
    */
   public Player(int type, int playerNum)
   {
      _type = type;
      _playerNum = playerNum;
      _hand = new Hand<Card>();
   }

   
   public void setTrump(int trump)
   {
      _trump = trump;
   }
   
   
   /**
    * Adds the given card to the hand
    * 
    * @param toAdd
    * @throws NullPointerException if the card is null
    */
   public void add(Card toAdd) throws NullPointerException
   {
      if(toAdd == null)
      {
         throw new NullPointerException();
      }
      
      _hand.add(toAdd);
   }
   
   
   /**
    * Removes a single card from the player's hand
    * 
    * @param toRemove the card to remove
    */
   public void remove(Card toRemove)
   {
      _hand.removeCard(toRemove);
   }
   
   
   /**
    * @param hand to assign to player
    */
   public void setHand(ArrayList<Card> hand)
   {
      for(Card card : hand)
      {
         _hand.add(card);
      }
   }
   
   /**
    * @return the player's cards
    */
   public ArrayList<Card> getHand()
   {
      return _hand;
   }
   
   
   /**
    * @return 1 if human player, 0 if AI
    */
   public int getType()
   {
      return _type;
   }
   
   
   /**
    * @return the player's number
    */
   public int getPlayerNum()
   {
      return _playerNum;
   }
   
   
   /**
    * @return trump 1 = diamonds, 2 = hearts, 3 = clubs, 4 = spades
    */
   public int getTrump()
   {
      return _trump;
   }
   
   
   /**
    * @return size of the hand.
    */
   public int getSize()
   {
       return _hand.size();
   }
   
   
   /**
    * Returns a boolean indicating if the player
    * has any cards left
    * 
    * @return true if the player has no more cards
    */
   public boolean isEmpty()
   {
      return _hand.size() == 0;
   }
}
